package com.dsj.gxrd.modules.book.domain.vo;

import com.dsj.gxrd.modules.book.domain.entity.RdBookCategory;
import io.swagger.annotations.ApiModel;
import lombok.Data;

import java.util.List;
import java.util.stream.Collectors;

/**
 * @author songpin566
 * @date 2023/10/16
 **/
@Data
@ApiModel("树形")
public class RdBookCatTree {

    private Long value;

    private String label;

    private Long parentId;

    private List<RdBookCatTree> children;

    public RdBookCatTree(){}

    public RdBookCatTree(RdBookCategory categoryEntity){
        this.value=categoryEntity.getRdBookCatId();
        this.label=categoryEntity.getBookCatName();
        this.parentId=categoryEntity.getParentId();
        List<RdBookCategory> list = categoryEntity.getChildren();
        if(list!=null&&list.size()>0){
            this.children = list.stream().map(RdBookCatTree::new).collect(Collectors.toList());
        }/*else {
            this.children=new ArrayList<>(0);
        }*/

    }

}
